package org.keyyond.ms.commonservice.dao;

import java.util.UUID;

import org.keyyond.ms.commonservice.mapper.SDBDUserMapper;
import org.keyyond.ms.commonservice.model.SDBDUser;
import org.keyyond.ms.commonservice.util.BaseDao;
import org.keyyond.ms.core.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.Page;

@Component
public class SDBDUserDao extends BaseDao<SDBDUser>{
	
	@Autowired 
	private SDBDUserMapper userMapper;

	public int getAllUsersCount(SDBDUser user) {
		// TODO Auto-generated method stub
		return userMapper.getAllUsersCount(user);
	}

	public Page<SDBDUser> selectAllByPage(SDBDUser user) {
		// TODO Auto-generated method stub
		return userMapper.selectAllByPage(user);
	}

	public SDBDUser selectByUsernameAndPassword(SDBDUser user) {
		// TODO Auto-generated method stub
		return userMapper.selectByUsernameAndPassword(user);
	}

	public int getUserCountByUsername(String userName) {
		// TODO Auto-generated method stub
		return userMapper.getUserCountByUsername(userName);
	}

	public int insert(SDBDUser user) {
		// TODO Auto-generated method stub
		user.setSeqno(UUID.randomUUID().toString());
		user.setCreateon(DateUtil.getTimestamp());
		user.setModifyon(DateUtil.getTimestamp());
		return userMapper.insert(user);
	}

	public int deleteUserBySeqno(String seqno) {
		// TODO Auto-generated method stub
		return userMapper.deleteByPrimaryKey(seqno);
	}

}
